*
*
*  Replication Code for "Community Donations, Public Goods Provision and Taxpayer Attitudes: Lessons from a Survey Experiment in Kenya"
* 
*
*/////////////////////////////////////////////////////////

cd "C:\Users\xahsce\Desktop\PhD Economics\Projects\Tax SSA Project\Data" 

capture log close 

log using "ReplicationLog.log"

use "ReplicationData.dta", replace 

*///////////////////// MAIN PAPER //////////////////////

*-------------------------------------Table 2


*Column 1-3


reg PayTax ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust 
est store reg1 

reg Justifiable ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust 
est store reg2 

reg TrustGov ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust 
est store reg3

*Column 4-6, Restricting analysis to people who report to have enough income do be eligible to pay tax 

reg PayTax ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute  ib0.GenderAttribute ib0.EarningsAttribute if EnoughIncome==1, robust 

est store reg4

reg Justifiable ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute  ib0.GenderAttribute ib0.EarningsAttribute if EnoughIncome==1, robust 

est store reg5 

reg TrustGov ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute  ib0.GenderAttribute ib0.EarningsAttribute if EnoughIncome==1, robust 

est store reg6


*Combining all regressions into one table
esttab reg1 reg2 reg3 reg4 reg5 reg6  using maineffects.tex, se label replace booktabs ///
alignment (D{.}{.}{-1}) ///
title(Average Treatment Effects\label{Table:maineffects})


*////////////// APPENDIX //////////////////


*----------------------------Table A1

* The table was created manually by observing the results from the following tabs 

tab GenderAttribute
tab EarningsAttribute
tab ServiceProvisionAttribute
tab LocalContributionsAttribute
tab FairnessAttribute
tab TransparencyAttribute
tab DetectionAttribute
tab FineAttribute

*----------------------------Table A2

* The table was created manually by observing the results from the following summarize, detail


sum PayTax, d
sum Justifiable, d 
sum TrustGov, d
sum RespDetection, d
sum RespTaxBenefit, d
sum RespCommunityGoods, d
sum RespContributed, d
sum Female, d
sum Age, d
sum Education, d
sum Works, d
sum Rural, d

*----------------------------Table A3

* The table was created manually by observing the results from the following tabs

tab PayTaxRaw
tab JustifiableRaw
tab TrustRaw
*----------------------------Table A4

logit PayTax ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust 

est store reg1 

logit Justifiable ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust 
est store reg2

logit TrustGov ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust 
est store reg3


*Combining all regressions into one table
esttab reg1 reg2 reg3  using mainlogistic.tex, se label replace booktabs ///
alignment (D{.}{.}{-1}) ///
title( Average Treatment Effects Logistic Regression \label{Table:mainlogistic})

*----------------------------Table A5 

reg LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute ib0.DetectionAttribute ib0.FineAttribute  ib0.GenderAttribute ib0.EarningsAttribute, robust

est store reg1

reg ServiceProvisionAttribute ib0.LocalContributionsAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute  ib0.GenderAttribute ib0.EarningsAttribute, robust

est store reg2

reg FairnessAttribute ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute  ib0.GenderAttribute ib0.EarningsAttribute, robust

est store reg3

reg TransparencyAttribute ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute  ib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust

est store reg4

reg DetectionAttribute ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust

est store reg5 

reg FineAttribute ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute ib0.DetectionAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust

est store reg6


reg GenderAttribute ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute ib0.DetectionAttribute ib0.FineAttribute ib0.EarningsAttribute, robust

est store reg7

reg EarningsAttribute ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute ib0.DetectionAttribute ib0.FineAttribute ib0. GenderAttribute, robust

est store reg8

*Combining all regressions into one table
esttab reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 using crossbalance.tex, se label replace booktabs ///
alignment (D{.}{.}{-1}) ///
title(Cross Balance\label{Table:crossbalance})

*----------------------------Table A6

reg LocalContributionsAttribute c.Age##c.Age Female EverEmployed EnoughIncome SecondaryEducation Rural, robust

est store reg1

reg ServiceProvisionAttribute c.Age##c.Age Female EverEmployed EnoughIncome SecondaryEducation Rural, robust

est store reg2

reg FairnessAttribute c.Age##c.Age Female EverEmployed EnoughIncome SecondaryEducation Rural, robust

est store reg3

reg TransparencyAttribute c.Age##c.Age Female EverEmployed EnoughIncome SecondaryEducation Rural, robust

est store reg4

reg DetectionAttribute c.Age##c.Age Female EverEmployed EnoughIncome SecondaryEducation Rural, robust

est store reg5

reg FineAttribute c.Age##c.Age Female EverEmployed EnoughIncome SecondaryEducation Rural, robust
est store reg6

reg GenderAttribute c.Age##c.Age Female EverEmployed EnoughIncome SecondaryEducation Rural, robust

est store reg7

reg EarningsAttribute c.Age##c.Age Female EverEmployed EnoughIncome SecondaryEducation Rural, robust

est store reg8

*Combining all regressions into one table
esttab reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 using covbalance.tex, se label replace booktabs ///
alignment (D{.}{.}{-1}) ///
title( Factor and Respondent Characteristics Balance\label{Table:covbalance})


*----------------------------Table A7 

* We start by creating the mean centered control variables, which are later used in the analysis below. 

* Centering Age
egen mean_Age = mean(Age)
gen meancage = Age - mean_Age

* Centering Female
egen mean_Fem = mean(Female)
gen meancfem = Female - mean_Fem

* Centering EverEmployed
egen mean_EverEmployed = mean(EverEmployed)
gen meancempl = EverEmployed - mean_EverEmployed

* Centering EnoughIncome
egen mean_EnoughIncome = mean(EnoughIncome)
gen meanceninc = EnoughIncome - mean_EnoughIncome

* Centering Education 
egen mean_SecondaryEducation=mean( SecondaryEducation)
gen meancsedu= SecondaryEducation-mean_SecondaryEducation

* Rural 
egen mean_Rural=mean(Rural)
gen meancrural= Rural-mean_Rural

*--Estimation of main effects with mean centered covariates


reg PayTax (ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute)##(c.meancage c.meancfem c.meancempl c.meanceninc c.meancsedu c.meancrural) , robust 
est store reg1 

reg Justifiable (ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute)##(c.meancage c.meancfem c.meancempl c.meanceninc c.meancsedu c.meancrural) , robust 
est store reg2 

reg TrustGov (ib0.LocalContributionsAttribute ib0.ServiceProvisionAttribute ib0.FairnessAttribute ib0.TransparencyAttribute iib0.DetectionAttribute ib0.FineAttribute ib0.GenderAttribute ib0.EarningsAttribute)##(c.meancage c.meancfem c.meancempl c.meanceninc c.meancsedu c.meancrural) , robust 
est store reg3

*Combining all regressions into one table
esttab reg1 reg2 reg3  using mainmeancent.tex, se label replace booktabs ///
alignment (D{.}{.}{-1}) ///
title(Main Effects With Mean Centered Covariates \label{Table:mainmeancent})

*----------------------------Table A8 

reg PayTax ib0.LocalContributionsAttribute  ib0.ServiceProvisionAttribute ServiceProvisionAttribute#LocalContributionsAttribute ib0.FairnessAttribute ib0.TransparencyAttribute FairnessAttribute#TransparencyAttribute ib0.DetectionAttribute ib0.FineAttribute DetectionAttribute#FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust 

est store reg1 

reg Justifiable ib0.LocalContributionsAttribute  ib0.ServiceProvisionAttribute ServiceProvisionAttribute#LocalContributionsAttribute ib0.FairnessAttribute ib0.TransparencyAttribute FairnessAttribute#TransparencyAttribute ib0.DetectionAttribute ib0.FineAttribute DetectionAttribute#FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust 

est store reg2

reg TrustGov ib0.LocalContributionsAttribute  ib0.ServiceProvisionAttribute ServiceProvisionAttribute#LocalContributionsAttribute ib0.FairnessAttribute ib0.TransparencyAttribute FairnessAttribute#TransparencyAttribute ib0.DetectionAttribute ib0.FineAttribute DetectionAttribute#FineAttribute ib0.GenderAttribute ib0.EarningsAttribute, robust 
est store reg3


*Combining all regressions into one table
esttab reg1 reg2 reg3 using interactions.tex, se label replace booktabs ///
alignment (D{.}{.}{-1}) ///
title(Factor Interactions \label{Table:interactions})

*----------------------------Table A9 

reg PayTax ib0.LocalContributionsAttribute  ib0.ServiceProvisionAttribute ServiceProvisionAttribute#LocalContributionsAttribute ib0.FairnessAttribute ib0.TransparencyAttribute FairnessAttribute#TransparencyAttribute ib0.DetectionAttribute ib0.FineAttribute DetectionAttribute#FineAttribute ib0.GenderAttribute ib0.EarningsAttribute if EnoughIncome==1, robust 

est store reg1 

reg Justifiable ib0.LocalContributionsAttribute  ib0.ServiceProvisionAttribute ServiceProvisionAttribute#LocalContributionsAttribute ib0.FairnessAttribute ib0.TransparencyAttribute FairnessAttribute#TransparencyAttribute ib0.DetectionAttribute ib0.FineAttribute DetectionAttribute#FineAttribute ib0.GenderAttribute ib0.EarningsAttribute if EnoughIncome==1, robust 

est store reg2

reg TrustGov ib0.LocalContributionsAttribute  ib0.ServiceProvisionAttribute ServiceProvisionAttribute#LocalContributionsAttribute ib0.FairnessAttribute ib0.TransparencyAttribute FairnessAttribute#TransparencyAttribute ib0.DetectionAttribute ib0.FineAttribute DetectionAttribute#FineAttribute ib0.GenderAttribute ib0.EarningsAttribute if EnoughIncome==1, robust 
est store reg3

*Combining all regressions into one table
esttab reg1 reg2 reg3 using interactionsinc.tex, se label replace booktabs ///
alignment (D{.}{.}{-1}) ///
title( Interactions Eligible Income Sample \label{Table:interactionsinc})

*----------------------------Table A10 

* The MDEs were manually calculated by multiplying 2.8 by the standard errors of the estimates in table 2 as per the process described in appendix section B.2. 

capture log close

 keep PayTax Justifiable TrustGov LocalContributionsAttribute ServiceProvisionAttribute FairnessAttribute TransparencyAttribute  DetectionAttribute FineAttribute GenderAttribute EarningsAttribute EnoughIncome RespDetection RespTaxBenefit RespCommunityGoods RespContributed Female Age Education Works Rural PayTaxRaw JustifiableRaw TrustRaw EverEmployed SecondaryEducation

 
 label variable PayTax                     "Thinks person should pay the tax"
label variable Justifiable                "Thinks it is justifiable if person evades taxes"
label variable TrustGov                   "Trusts government to use tax funds properly"

label variable LocalContributionsAttribute "Large (vs small) donation to community goods"
label variable ServiceProvisionAttribute   "Good (vs poor) access to services"
label variable FairnessAttribute           "Equally (vs unequally) distributed resources"
label variable TransparencyAttribute       "A lot (vs little) information about tax fund use"
label variable DetectionAttribute          "Likely (vs unlikely) detection of tax evasion"
label variable FineAttribute               "Large (vs small) fine for evasion"

label variable GenderAttribute             "Female (vs male)"
label variable EarningsAttribute           "Earns 120,000 (vs 30,000)"
label variable EnoughIncome                "Respondent reports income sufficiently large to be eligible for PAYE"

label variable RespDetection               "Respondent Perception: likelihood of detecting evasion"
label variable RespTaxBenefit              "espondent Perception: taxpayers benefit from public goods and services"
label variable RespCommunityGoods          "Respondent heard about  donation initiatives in their community (past year)"
label variable RespContributed             "Respondent contributed (past year)"

label variable Female                      "Respondent is female"
label variable Age                         "Respondent age (years)"
label variable Education                   "Years of education"
label variable Works                       "Currently employed"
label variable Rural                       "Lives in rural area"

label variable PayTaxRaw                   "Raw measure of PayTax"
label variable JustifiableRaw              "Raw measure of Justifiable"
label variable TrustRaw                    "Raw measure of TrustGov"
label variable EverEmployed                "Has ever been employed"
label variable SecondaryEducation          "Has at least secondary education"



